﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace SDFL.Utilities
{
    /// <summary>
    /// Log to Console
    /// </summary>
    /// <history>
    ///     [Dylan]     2009-10-19      Created
    /// </history>
    internal class ConsoleLog: LogBase
    {
        public ConsoleLog(): this(false)
        {

        }

        public ConsoleLog(bool verbose): base(false)
        {
                        
        }

        public override void WriteEntry(EntryType entryType, string info)
        {
            if (entryType != EntryType.Verbose || this.Verbose && entryType == EntryType.Verbose)
            {
                Console.WriteLine(info);
            }            
        }

        public override void LogFailure(Exception ex, string info, string bugNumber)
        {
            if (ex == null)
            {
                WriteEntry(EntryType.Failure, "!!!SCENARIO FAILURE!!!" + "\n" +
                 "  Info:       " + info + "\n" +
                 "  Bug #       " + bugNumber + "\n");
            }
            else
            {
                WriteEntry(EntryType.Failure, "!!!SCENARIO FAILURE!!!" + "\n" +
                 "  Exception:  " + ex.ToString() + "\n" +
                 "  Info:       " + info + "\n" +
                 "  Bug #       " + bugNumber + "\n");
            }
            
        }

        public override void LogPass(string info)
        {
            WriteEntry(EntryType.Standard, "!!!SCENARIO SUCCESS!!!" + "\n" +
                "   Info:   " + info + "\n");
        }

        public override void LogPass()
        {
            WriteEntry(EntryType.Standard, "!!!SCENARIO SUCCESS!!!" + "\n");
        }


        public override void InitScenario(string scenarioDescription)
        {
            WriteEntry(EntryType.Scenario,
                "\r\n" +
                "************************************************************************************************" + "\r\n" +
                "   Scenario:   " + scenarioDescription + "\r\n" +
                "   Start time: " + DateTime.Now + "\r\n" +
                "************************************************************************************************");
        }

        internal override void InitTestCase(string testcaseDescription)
        {
            WriteEntry(EntryType.Standard,
                "\r\n" +
                "################################################################################################" + "\r\n" +
                "   Testcase:   " + testcaseDescription + "\r\n" +
                "   Start time: " + DateTime.Now + "\r\n" +               
                "################################################################################################");
        }
    }
}
